package com.zuser.project.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfigLogin implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/keyou/**")          // 拦截所有/keyou开头的请求
                .excludePathPatterns(
                        "/keyou/login",              // 排除登录接口
                        "/keyou/system/sysmenu/list", // 测试时可以先排除这个路径
                        "/swagger-ui/**",
                        "/v3/api-docs/**"
                )
                .order(1);  // 设置拦截器顺序
    }
}